package com.lpinfo.spca.order.biz.controller;

import com.lpinfo.spca.order.api.dto.LpinfoOrderDto;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/order" )
public class OrderController {

    /////FIXME feign负载均衡测试
    @Value("${server.port}")
    private String port;

    //FIXME 详情
    @GetMapping("/getOrderById/{orderId}")
    public Object getOrderById(@PathVariable("orderId") Long orderId) {
        LpinfoOrderDto result = new LpinfoOrderDto();
        result.setOrderId(1L);
        result.setUserId(1L);
        result.setOrderNo("M2230230");
        result.setCreateTime(new Date());
        result.setCreateUser("user");
        result.setOrderPrice(new BigDecimal("20.00"));
        result.setPayChannel("1");
        result.setUserName("负载均衡测试"+port);
        return result;
    }

    //FIXME 详情
    @GetMapping("/getOrderListByUserId/{userId}")
    public Object getOrderListByUserId(@PathVariable("userId") Long userId) {
        LpinfoOrderDto order = new LpinfoOrderDto();
        order.setOrderId(1L);
        order.setUserId(1L);
        order.setOrderNo("M2230230");
        order.setCreateTime(new Date());
        order.setCreateUser("user");
        order.setOrderPrice(new BigDecimal("20.00"));
        order.setPayChannel("1");
        order.setUserName("负载均衡测试"+port);
        ArrayList result = new ArrayList();
        result.add(order);
        return result;
    }

}
